﻿using System;
using System.Collections.Generic;

namespace RexToy.Cassandra
{
    class SuperColumnCollection<C, SUB> : ISuperColumnCollection<C, SUB>
    {
        private List<ISuperColumn<C, SUB>> _list;
        internal SuperColumnCollection()
        {
            _list = new List<ISuperColumn<C, SUB>>();
        }

        public void AddColumn(ISuperColumn<C, SUB> column)
        {
            _list.Add(column);
        }

        public IColumn<C> this[C colName]
        {
            get
            {
                foreach (var sc in _list)
                {
                    if (sc.Name.Equals(colName))
                        return sc;
                }
                return null;
            }
        }

        public IEnumerator<IColumn<C>> GetEnumerator()
        {
            return _list.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return _list.GetEnumerator();
        }
    }
}
